package com.prs.crm.dao;

import java.sql.SQLException;
import java.util.Collection;

import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.HibernateCallback;

import com.prs.crm.dao.impl.BaseDaoImpl;
import com.prs.crm.domain.Teacher;

public class TeacherDaoImpl extends BaseDaoImpl<Teacher> implements TeacherDao {

	@SuppressWarnings("unchecked")
	@Override
	public Collection<Teacher> getAllTeachers() {
		return (Collection<Teacher>) this.getHibernateTemplate().execute(
				new HibernateCallback() {

					@Override
					public Object doInHibernate(Session arg0)
							throws HibernateException, SQLException {
						Criteria criteria = arg0.createCriteria(Teacher.class);
						System.out.println(criteria.list().size());
						return criteria.list();
					}
				});
		
	}

}
